﻿using EduCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace EduCenter.Filter
{
    /// <summary>
    /// 异常筛选器
    /// </summary>
    public class ExceptionAttribute : HandleErrorAttribute
    {
        public override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {//ajax异常处理
                filterContext.Result = new JsonResult() { Data = new { status = Result.error, message = filterContext.Exception.Message }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            }
            else
            {
                base.OnException(filterContext);
            }
        }
    }
}